wayland: Handle the display connection erroring out
authorRob Bradford <rob@linux.intel.com>
Tue, 9 Jul 2013 17:08:21 +0000 (18:08 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 9 Jul 2013 22:52:56 +0000 (18:52 -0400)
wl_display_flush or wl_display_dispatch can return -1 if there is an
error on the display connection.

https://bugzilla.gnome.org/show_bug.cgi?id=703892

gdk/wayland/gdkeventsource.c

index 4bcae9b285f72128d5181e2ffd967b7ecb2f7b17..619ee872c1f1e4a365c33bf4be5497abd0f42629 100644 (file)
@@ -20,6 +20,8 @@
 #include "gdkinternals.h"
 #include "gdkprivate-wayland.h"
 
+#include <errno.h>
+
 typedef struct _GdkWaylandEventSource {
   GSource source;
   GPollFD pfd;
@@ -47,7 +49,8 @@ gdk_event_source_prepare(GSource *base, gint *timeout)
   if (_gdk_event_queue_find_first (source->display) != NULL)
     return TRUE;
 
-  wl_display_flush(display->wl_display);
+  if (wl_display_flush (display->wl_display) < 0)
+    g_error ("Error dispatching display: %s", g_strerror (errno));
 
   return FALSE;
 }
@@ -152,7 +155,10 @@ _gdk_wayland_display_queue_events (GdkDisplay *display)
   source = (GdkWaylandEventSource *) display_wayland->event_source;
 
   if (source->pfd.revents & G_IO_IN)
-    wl_display_dispatch (display_wayland->wl_display);
+    {
+      if (wl_display_dispatch (display_wayland->wl_display) < 0)
+        g_error ("Error dispatching display: %s", g_strerror (errno));
+    }
 
   if (source->pfd.revents & (G_IO_ERR | G_IO_HUP))
     g_error ("Lost connection to wayland compositor");